﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RoadTeam.Standard;
using System.Web.Script.Serialization;
using RoadTeam.Pub;
using System.Data;
using RoadTeam.BLL;

public partial class 对接测试页面_CsAppeal : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        List<Appeal> li = new List<Appeal>();
        //生成插入Json
        Appeal appeal = new Appeal();
        appeal.AppealIdentities = String.Empty;
        appeal.AppealCode = @"100860001";
        appeal.AppealDate = DateTime.Now;
        appeal.AppealType = @"员工服务";
        appeal.AppealContent = @"进门的时候不和我打招呼";
        appeal.AppealContact = @"张三";
        appeal.AppealContactPhone = @"12345678910";
        appeal.AppealAddress = @"天河区天河北路689号光大银行711";
        appeal.AppealCreater = @"陈工";
        appeal.AppealRemark = @"这是是备注什么的";
        li.Add(appeal);
        appeal = new Appeal();
        appeal.AppealIdentities = String.Empty;
        appeal.AppealCode = @"100860002";
        appeal.AppealDate = DateTime.Now;
        appeal.AppealType = @"12306提交过来的投诉";
        appeal.AppealContent = @"进门的时候不帮我提东西";
        appeal.AppealContact = @"张三";
        appeal.AppealContactPhone = @"12345678910";
        appeal.AppealAddress = @"天河区天河北路689号光大银行711";
        appeal.AppealCreater = @"陈工";
        appeal.AppealRemark = @"这是是备注什么的";
        li.Add(appeal);
        appeal = new Appeal();
        appeal.AppealIdentities = String.Empty;
        appeal.AppealCode = @"100860003";
        appeal.AppealDate = DateTime.Now;
        appeal.AppealType = @"员工服务";
        appeal.AppealContent = @"厕所堵塞好几天都没有人管";
        appeal.AppealContact = @"张三";
        appeal.AppealContactPhone = @"12345678910";
        appeal.AppealAddress = @"天河区天河北路689号光大银行711";
        appeal.AppealCreater = @"陈工";
        appeal.AppealRemark = @"这是是备注什么的";
        li.Add(appeal);
        CsAppeal Appeal = new CsAppeal();
        Appeal.Item = li.ToArray();
        JavaScriptSerializer jvs = new JavaScriptSerializer();
        TextBox1.Text = ConverJson.ConverJsonDateTime(jvs.Serialize(Appeal));

    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        String Json = TextBox1.Text;
        JavaScriptSerializer jvs = new JavaScriptSerializer();
        CsAppeal Appeal = jvs.Deserialize<CsAppeal>(Json);
        CsAppealBLL bll = new CsAppealBLL();
        DataTable dt = bll.GetEmptyTable();
        DataRow dr;
        foreach (Appeal appeal in Appeal.Item)
        {
            dr = dt.NewRow();
            dr["AppealIdentities"] = RoadTeam.Pub.CreateIdentifier.GetIdentifier();
            dr["AppealCode"] = appeal.AppealCode;
            dr["AppealDate"] = appeal.AppealDate;
            dr["AppealType"] = appeal.AppealType;
            dr["AppealContent"] = appeal.AppealContent;
            dr["AppealContact"] = appeal.AppealContact;
            dr["AppealContactPhone"] = appeal.AppealContactPhone;
            dr["AppealAddress"] = appeal.AppealAddress;
            dr["AppealCreater"] = appeal.AppealCreater;
            dr["AppealRemark"] = appeal.AppealRemark;
            appeal.AppealIdentities = dr["AppealIdentities"].ToString();
            dt.Rows.Add(dr);
        }
        bll.Insert(dt, Json);
        Response.Write(jvs.Serialize(Appeal));
    }
}